package com.example.moviegroup.app;

import java.io.File;
import java.util.LinkedList;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Environment;
import android.util.DisplayMetrics;

import com.lidroid.xutils.HttpUtils;
import com.lidroid.xutils.bitmap.BitmapGlobalConfig;

/**
 * @author andy
 * 
 */
@SuppressLint("SdCardPath")
public class IApplication extends Application {
	public static final boolean debugOn = true;// 日志打印开关 123123123
	private static Context mContext;
	public static int displayWidth;
	public static int displayHeight;
	@Override
	public void onCreate() {
		super.onCreate();
		mContext = getApplicationContext();
		DisplayMetrics dm = getApplicationContext().getResources()
				.getDisplayMetrics();
		displayWidth = dm.widthPixels;
		displayHeight = dm.heightPixels;
	}

	/**
	 * 判断网络是否可用
	 * 
	 * @param context
	 * @return
	 */
	public static boolean isNetworkAvailable(Context context) {
		// 1,得到网络的管理类
		ConnectivityManager manager = (ConnectivityManager) context
				.getSystemService(Context.CONNECTIVITY_SERVICE);
		// 2,得到网络的信息
		NetworkInfo networkinfo = manager.getActiveNetworkInfo();
		// 3,判断网络是否可用
		if (networkinfo == null)
			return false;
		return networkinfo.isAvailable() && networkinfo.isConnected();
	}


	/**
	 * 获取Context对象
	 * 
	 * @return
	 */
	public static Context getContext() {
		return mContext;
	}
}
